package com.ruoyi.bussiness.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.CcyBaseInfo;
import com.ruoyi.bussiness.service.ICcyBaseInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数字货币Controller
 * 
 * @author wzy
 * @date 2025-10-19
 */
@RestController
@RequestMapping("/bussiness/info")
public class CcyBaseInfoController extends BaseController
{
    @Autowired
    private ICcyBaseInfoService ccyBaseInfoService;

    /**
     * 查询数字货币列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcyBaseInfo ccyBaseInfo)
    {
        startPage();
        List<CcyBaseInfo> list = ccyBaseInfoService.selectCcyBaseInfoList(ccyBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出数字货币列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:export')")
    @Log(title = "数字货币", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcyBaseInfo ccyBaseInfo)
    {
        List<CcyBaseInfo> list = ccyBaseInfoService.selectCcyBaseInfoList(ccyBaseInfo);
        ExcelUtil<CcyBaseInfo> util = new ExcelUtil<CcyBaseInfo>(CcyBaseInfo.class);
        util.exportExcel(response, list, "数字货币数据");
    }

    /**
     * 获取数字货币详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccyBaseInfoService.selectCcyBaseInfoById(id));
    }

    /**
     * 新增数字货币
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:add')")
    @Log(title = "数字货币", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcyBaseInfo ccyBaseInfo)
    {
        return toAjax(ccyBaseInfoService.insertCcyBaseInfo(ccyBaseInfo));
    }

    /**
     * 修改数字货币
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:edit')")
    @Log(title = "数字货币", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcyBaseInfo ccyBaseInfo)
    {
        return toAjax(ccyBaseInfoService.updateCcyBaseInfo(ccyBaseInfo));
    }

    /**
     * 删除数字货币
     */
    @PreAuthorize("@ss.hasPermi('bussiness:info:remove')")
    @Log(title = "数字货币", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccyBaseInfoService.deleteCcyBaseInfoByIds(ids));
    }
}
